package com.TabHost.test;


import android.app.TabActivity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TabHost;
import android.widget.RadioGroup.OnCheckedChangeListener;

public class Tabhost extends TabActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		final TabHost tabHost = getTabHost();
		// tabHost = (TabHost) findViewById(android.R.id.tabhost);
		TabHost.TabSpec homeSpec = tabHost.newTabSpec("Home");
		homeSpec.setIndicator(getString(R.string.tab_a));
		homeSpec.setContent(new Intent(this, Home.class));
		tabHost.addTab(homeSpec);

		TabHost.TabSpec msgSpec = tabHost.newTabSpec("Message");
		msgSpec.setIndicator(getString(R.string.tab_b));
		msgSpec.setContent(new Intent(this, Msg.class));
		tabHost.addTab(msgSpec);

		TabHost.TabSpec helpSpec = tabHost.newTabSpec("Help");
		helpSpec.setIndicator(getString(R.string.tab_c));
		helpSpec.setContent(new Intent(this, Help.class));
		tabHost.addTab(helpSpec);
		
		TabHost.TabSpec aboutSpec = tabHost.newTabSpec("About");
		aboutSpec.setIndicator(getString(R.string.tab_d));
		aboutSpec.setContent(new Intent(this, About.class));
		tabHost.addTab(aboutSpec);
		
		RadioGroup radioGroup = (RadioGroup) findViewById(R.id.main_radio);
		RadioButton homeRadio = (RadioButton) findViewById(R.id.tab_a);
		
		homeRadio.setChecked(true);
		radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				switch (checkedId) {
				case R.id.tab_a:
					tabHost.setCurrentTabByTag("Home");					
					break;
				case R.id.tab_b:
					tabHost.setCurrentTabByTag("Message");					
					break;
				case R.id.tab_c:
					tabHost.setCurrentTabByTag("Help");
					break;
				case R.id.tab_d:
					tabHost.setCurrentTabByTag("About");
					break;
				default:
					break;
				}
			}
		});			
		
	}
	
	
	
	
}
